| Reply | « Previous Thread | Next Thread » |
|
Hi,
I've got a little problem with threads in Python. Up to now, I only know Threads from Java, but it should be similar in Python. The following code refreshes an image on the display if the accelerometer gets a specific orientation event! That works fine. Additionally it should now play a specific mp3 for a specific orientation event (parallel/synchronized to refreshing the image). I tried to realize this by the code marked in red! Code:
...
args = "", ""
soundFB = thread
def paintScreen(range, source):
canvas.blit(source)
def playSound(empty1, empty2):
input = UpSound
input.set_volume(2)
input.play(times=1, interval=0, callback=None)
input.stop()
def print_orientation(orientation_value):
#print >> to_peer, orientations[orientation_value]
if orientations[orientation_value] == 'Up':
paintScreen((), UpImage)
soundFB.start_new_thread(playSound, args)
...
The "playSound" method seems to start, the image becomes refreshed, but no sound is played and then the whole application freezes. (the playSound method on it's own works fine! It's just the combination with the thread!) Can anybody give me an advise how to handle this problem? |
|
Quote:
Threads on Python mostly work fine - like threads on Java. But threads on Symbian are f*cked up. Namely, you cannot share native objects across the threads (files, sockets). This is due to limitations in Symbian "server" architecture. Usual symptoms are untraceable lock ups or application crashes. Also, some functions are callable on the main thread only. Internally PyS60 maps threads to Symbian Active Objects - read more about architectural limitations here - article about Microsoft trying port .NET framework on Symbian: http://www.jot.fm/issues/issue_2006_04/article4/ 1. Try create all objects in the same thread they are accessed. 2. See multithread debugging/exception tracing tips from this example app: http://bazaar.launchpad.net/~pys60co...7in81mt9gmhv-6 Mikko Ohtamaa Twinapex Research http://www.twinapex.com |
|
Hi,
up to now my application runs stable (including the audio thread), but one thing is mysterious. The "playSound" method runs in a thread without exceptions, the audio states are correct and the sound is played, but I can't hear the sound! I've checked my mobile phone profile ("general") two times. Is it generally impossible to run the audio module in a thread?!?! With a normal call (without thread) the same method runs well and I can hear the sound. ![]() |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Rate This Thread | |
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| Difference between handling HTTP session in threads and without threads | LavanyaSpm | General Symbian C++ | 0 | 2008-09-22 12:37 |
| Porting to Symbian: threads, timers, active objects problem | thanhtranhd | General Symbian C++ | 3 | 2008-02-01 00:54 |
| Threads List in an application | mailkamlesh | General Symbian C++ | 1 | 2007-11-26 09:07 |
| Message to everybody - STOP USING THREADS | hotcheese | General Symbian C++ | 8 | 2007-03-05 13:18 |
| mixing AO, threads and sockets | mikfi | Symbian Networking & Messaging | 6 | 2006-11-22 00:19 |