|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Thread that calls SeekControl's seek method. |
|
15 * |
|
16 */ |
|
17 |
|
18 package com.nokia.microedition.media.protocol; |
|
19 |
|
20 import com.nokia.microedition.media.SeekControl; |
|
21 import com.nokia.mj.impl.utils.Logger; |
|
22 |
|
23 /** |
|
24 * Thread that calls SeekControl's seek method. |
|
25 */ |
|
26 class SeekThread extends Thread |
|
27 { |
|
28 // control to call in run method |
|
29 final private SeekControl iSeekControl; |
|
30 |
|
31 // object to notify when seek is ready |
|
32 final private Object iWaitObject; |
|
33 |
|
34 /** |
|
35 * Public constructor. |
|
36 * @param aWwaitObject Object to notify when ready |
|
37 * @param aSeekControl Control to seek. |
|
38 */ |
|
39 public SeekThread(Object aWaitObject, |
|
40 SeekControl aSeekControl) |
|
41 { |
|
42 iWaitObject = aWaitObject; |
|
43 iSeekControl = aSeekControl; |
|
44 } |
|
45 |
|
46 /** |
|
47 * From Thread class. |
|
48 */ |
|
49 public void run() |
|
50 { |
|
51 try |
|
52 { |
|
53 iSeekControl.seek(0); |
|
54 } |
|
55 catch (Exception e) |
|
56 { |
|
57 // If seek fails, stream cannot be read and SeekControl's target |
|
58 // read must return -1 or throw an exception. |
|
59 Logger.ELOG(Logger.EJavaMMAPI, |
|
60 "MMA::SourceStreamReader::read seek exception ", e); |
|
61 } |
|
62 |
|
63 // notify that seek is ready |
|
64 synchronized (iWaitObject) |
|
65 { |
|
66 iWaitObject.notify(); |
|
67 } |
|
68 } |
|
69 } |