Por que o som não seria ouvido no telefone quando ele funciona na área de trabalho com um aplicativo do Ubuntu Touch?

3

Eu tenho um aplicativo do Ubuntu Touch em andamento. O aplicativo precisa reproduzir o som. Eu usei QtMultimedia de C ++ para reprodução de som. O som toca bem no PC, mas não no telefone.

O mais estranho é que ao executar o aplicativo no telefone usando o QtCreator e o Build → Ubuntu → Executar o aplicativo no dispositivo, o som é reproduzido muito bem. Ao instalar o aplicativo no telefone e usar o Build → Ubuntu → Instalar o aplicativo no dispositivo e, em seguida, executá-lo a partir do Dash do telefone, o som não é ouvido. Meu ambiente de desenvolvimento é o Ubuntu 14.04 e o telefone roda o Ubuntu Touch (trusty) v250.

Para referência, aqui está o trecho de código que usei para a reprodução real:

Playlist::Playlist(QObject *parent) :
    QObject(parent),
    m_trackListHandler(new TrackListHandler()),
    m_playlist(new QMediaPlaylist()),
    m_player(new QMediaPlayer()),
    m_currentIndex(0)
{
    m_player->setPlaylist(m_playlist);
}

void Playlist::playTrack(int index)
{
    if (index < m_trackList.count())
    {
        m_playlist->setCurrentIndex(index);
        m_currentIndex = index;
        m_player->play();

        emit playbackStarted(m_trackList.at(index));
    }
}

void Playlist::resumePlayback()
{
    // ...
}

void Playlist::pause()
{
    // ...
}

void Playlist::nextTrack()
{
    // ...
}

void Playlist::previousTrack()
{
    // ...
}

void Playlist::appendTrack(PTrack track)
{
    // ...
}

void Playlist::appendAndPlay(PTrack track)
{
    // ...
}

O código fonte completo para playlist.h:

#include "playlist.h"

#include "album.h"
#include "track.h"
#include "tracklisthandler.h"

#include <QMediaPlaylist>
#include <QMediaPlayer>

#include "logger.h"

Playlist & Playlist::instance()
{
    static Playlist instance;

    return instance;
}

Playlist::Playlist(QObject *parent) :
    QObject(parent),
    m_trackListHandler(new TrackListHandler()),
    m_playlist(new QMediaPlaylist()),
    m_player(new QMediaPlayer()),
    m_currentIndex(0)
{
    LOG_INFO << "called";
    m_player->setPlaylist(m_playlist);
}

Playlist::~Playlist()
{
    delete m_trackListHandler;
    delete m_playlist;
    delete m_player;
}


void Playlist::playTrack(int index)
{
    LOG_INFO << "called";

    if (index < m_trackList.count())
    {
        m_playlist->setCurrentIndex(index);
        m_currentIndex = index;
        m_player->play();

        emit playbackStarted(m_trackList.at(index));
    }
}

void Playlist::resumePlayback()
{
    LOG_INFO << "called";
    m_player->play();

    emit playbackStarted(m_trackList.at(m_currentIndex));
}

void Playlist::pause()
{
    LOG_INFO << "called";
    m_player->pause();
}

void Playlist::nextTrack()
{
    LOG_INFO << "called";
    int nextIndex = m_currentIndex + 1;

    if (nextIndex >= m_trackList.count())
    {
        nextIndex = 0;
    }

    m_currentIndex = nextIndex;
    m_playlist->setCurrentIndex(m_currentIndex);
    m_player->play();

    emit playbackStarted(m_trackList.at(m_currentIndex));
}

void Playlist::previousTrack()
{
    LOG_INFO << "called";
    int previousIndex = m_currentIndex - 1;

    if (previousIndex <= 0)
    {
        previousIndex = m_trackList.count() - 1;
    }

    m_currentIndex = previousIndex;
    m_playlist->setCurrentIndex(m_currentIndex);
    m_player->play();

    emit playbackStarted(m_trackList.at(m_currentIndex));
}

void Playlist::appendTrack(PTrack track)
{
    LOG_INFO << "called";
    m_trackList.append(track);
    m_playlist->addMedia(m_trackListHandler->streamUrl(track));

    emit playlistChanged();
}

void Playlist::appendAndPlay(PTrack track)
{
    LOG_INFO << "called";
    m_trackList.append(track);
    m_playlist->addMedia(m_trackListHandler->streamUrl(track));
    m_currentIndex = m_trackList.indexOf(track);
    m_playlist->setCurrentIndex(m_currentIndex);
    m_player->play();

    emit playlistChanged();
    emit playbackStarted(track);
}

TrackList Playlist::tracks() const
{
    return m_trackList;
}

void Playlist::clear()
{
    m_trackList.clear();
    m_playlist->clear();
}

int Playlist::count() const
{
    return m_trackList.count();
}

O arquivo Playlist.cpp:

#ifndef PLAYLIST_H
#define PLAYLIST_H

#include <QObject>

#include "common.h"

class TrackListHandler;
class QMediaPlaylist;
class QMediaPlayer;

class Playlist : public QObject
{
    Q_OBJECT

public:
    static Playlist &instance();

public:
    void playTrack(int index);
    void resumePlayback();
    void pause();
    void nextTrack();
    void previousTrack();

    void appendAndPlay(PTrack track);
    void appendTrack(PTrack track);

    TrackList tracks() const;
    void clear();
    int count() const;

signals:
    void playlistChanged();
    void playbackStarted(PTrack track);

private:
    TrackList m_trackList;
    TrackListHandler *m_trackListHandler;
    QMediaPlaylist *m_playlist;
    QMediaPlayer *m_player;
    int m_currentIndex;

private:
    Playlist(QObject *parent = 0);
    virtual ~Playlist();

    Playlist(Playlist const &): QObject(0) { }

    Playlist &operator =(Playlist const &) { return *this; }
};

#endif // PLAYLIST_H

O log do aplicativo:

playlist.cpp 111 void Playlist::appendAndPlay(PTrack) INFO: called 
shm_open() failed: Permission denied
Failed to create secure directory (/run/user/32011/pulse): Permission denied
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
GStreamer; Unable to pause - "http://192.168.0.110:4040/rest/stream.view?&v=1.10.2&c=ro.kicsyromy.playsonic&id=396" 
shm_open() failed: Permission denied
Failed to create secure directory (/run/user/32011/pulse): Permission denied
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
GStreamer; Unable to play - "http://192.168.0.110:4040/rest/stream.view?&v=1.10.2&c=ro.kicsyromy.playsonic&id=396" 
playlistmodel.cpp 33 virtual QVariant PlaylistModel::data(const QModelIndex&, int) const INFO: called for index 0 
playlistmodel.cpp 33 virtual QVariant PlaylistModel::data(const QModelIndex&, int) const INFO: called for index 0 
playlistmodel.cpp 33 virtual QVariant PlaylistModel::data(const QModelIndex&, int) const INFO: called for index 0 
Error: "Could not initialize supporting library." 

O arquivo manifest.json:

{
    "architecture": "all",
    "description": "Player client for Subsonic and Subsonic API compatible servers",
    "framework": "ubuntu-sdk-13.10",
    "hooks": {
        "Playsonic": {
            "apparmor": "Playsonic.json",
            "desktop": "Playsonic.desktop"
        }
    },
    "maintainer": "Romeo Calota",
    "name": "ro.kicsyromy.playsonic",
    "title": "Playsonic",
    "version": "0.1"
}

O perfil do AppArmor:

{
    "policy_groups": [
        "networking",
        "audio",
        "accounts",
        "audio",
        "calendar",
        "camera",
        "connectivity",
        "contacts",
        "content_exchange",
        "content_exchange_source",
        "friends",
        "history",
        "location",
        "microphone",
        "music_files",
        "music_files_read",
        "networking",
        "picture_files",
        "picture_files_read",
        "sensors",
        "usermetrics",
        "video",
        "video_files",
        "video_files_read"
    ],
    "policy_version": 1
}
    
por kicsyromy 03.04.2014 / 17:19

1 resposta

1

Você adicionou "áudio" à sua política de segurança? Vá para a seção "Publish" no QtCreator, então na lista "Security Policy Groups", clique no botão "+" e adicione "audio". Em seguida, tente instalar o pacote no dispositivo novamente e veja se funciona.

O motivo pelo qual suspeito é que, quando simplesmente executamos o código no dispositivo, o QtCreator copia os arquivos para um local temporário e os inicia a partir da linha de comando, para que eles sejam executados sem confinamento. Mas ao instalá-lo a partir do pacote de cliques, ele ficará confinado à política de segurança definida nesse pacote.

Consulte o link para obter mais informações sobre políticas de confinamento e segurança.

    
por mhall119 03.04.2014 / 17:42